﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using FS.Business;
using FS.Common.DotNetCode;
using FS.Common.DotNetUI;

namespace FS.Web.BLL.Visa
{
    public partial class Visa_PostVisaList : PageBase
    {
        private visa_dao _visa = new visa_dao();
        protected void Page_Load(object sender, EventArgs e)
        {
            this.PageControl1.pageHandler += new EventHandler(this.pager_PageChanged);
            if (!base.IsPostBack)
            {
                this.begdate.Value = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
                this.enddate.Value = DateTime.Now.ToString("yyyy-MM-dd");
            }
        }
        protected void pager_PageChanged(object sender, EventArgs e)
        {
            this.DataBindGrid();
        }
        private void DataBindGrid()
        {
            int count = 0;
            if (this.Hchange.Value == "1")
            {
                this.PageControl1.PageIndex = 1;
                this.Hchange.Value = "0";
            }
            StringBuilder SqlWhere = new StringBuilder();
            IList<SqlParam> IList_param = new List<SqlParam>();
            if (!string.IsNullOrEmpty(this.txt_Search.Value))
            {
                SqlWhere.Append(" and " + this.Searchwhere.Value + " like @obj ");
                IList_param.Add(new SqlParam("@obj", '%' + this.txt_Search.Value.Trim() + '%'));
            }
            SqlWhere.Append(" and info.info_getdate>= @begdate ");
            SqlWhere.Append(" and info.info_getdate<= @enddate ");            
            IList_param.Add(new SqlParam("@begdate", this.begdate.Value));
            IList_param.Add(new SqlParam("@enddate", this.enddate.Value));

            DataTable dt = this._visa.GetPostVisaInfoPage(SqlWhere, IList_param, this.PageControl1.PageIndex, this.PageControl1.PageSize, ref count);
            ControlBindHelper.BindRepeaterList(dt, this.rp_Item);
            this.PageControl1.SetPageCount(count);
        }

        protected void lbtSearch_Click(object sender, EventArgs e)
        {
            this.DataBindGrid();
        }
    }
}